package com.wangyadong.hobby.front.model;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.SmartLifecycle;
import org.springframework.lang.Nullable;

public class MyFirstLifeCycle implements SmartLifecycle {

    private final Log logger = LogFactory.getLog(this.getClass());
    private volatile long timeoutPerShutdownPhase = 30000L;
    private volatile boolean running;
    private String id;
    @Nullable
    private volatile ConfigurableListableBeanFactory beanFactory;

    @Override
    public boolean isAutoStartup() {
        return true;
    }

    @Override
    public void stop(Runnable runnable) {
        System.out.println("stop MyFirstLifeCycle runnable" );
        new Thread(runnable).start();
    }

    @Override
    public void start() {
        System.out.println("start MyFirstLifeCycle " + beanFactory);
    }

    @Override
    public void stop() {
        System.out.println("stop MyFirstLifeCycle");
    }

    @Override
    public boolean isRunning() {
        return true;
    }

    @Override
    public int getPhase() {
        return -1;
    }


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }
}
